import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
from langchain_community.vectorstores import FAISS
from langchain.docstore.document import Document
# from langchain_community.embeddings import HuggingFaceBgeEmbeddings
from customize.langchain_customized_huggingface import HuggingFaceBgeEmbeddings
raw_documents = [Document(page_content="葡萄", metadata={"source": "local"}),
Document(page_content="白菜", metadata={"source": "local"}),
Document(page_content="狗", metadata={"source": "local"})]
#embeddings = OllamaEmbeddings(base_url="10.12.8.21:11434", model="qwen2.5:14b")

model_path = "F:/models/BAAI/bge-large-zh-v1.5"
model_name = "BAAI/bge-large-zh-v1.5"
model_kwargs = {'device': 'cuda'}
encode_kwargs = {'normalize_embeddings': True}  # set True to compute cosine similarity
embeddings = HuggingFaceBgeEmbeddings(
    model_name=model_name,
    model_path=model_path,
    query_instruction="为这个句子生成表示以用于检索相关文章："
)
db = FAISS.from_documents(raw_documents, embeddings)
query = "动物"
docs = db.similarity_search(query)
print(docs[0].page_content)